package com.changgou.seckill.controller;

import com.changgou.seckill.pojo.SeckillGoods;
import com.changgou.seckill.service.SeckillGoodsService;
import entity.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @author:hushengjin
 * @date:2019-08-12 20:49:32
 */

@RestController
@RequestMapping(value = "/seckill/goods")
@CrossOrigin
public class SeckillGoodsController {

    @Autowired
    private SeckillGoodsService seckillGoodsService;


    /**
     * 获取时间菜单
     * URL:/seckill/goods/menus
     */
    @RequestMapping(value = "/menus")
    public List<Date> dateMenus() {
        return DateUtil.getDateMenus();
    }

    /**
     * 获取指定时间段的商品列表
     *
     * @param time
     * @return
     */
    @RequestMapping(value = "/list")
    public List<SeckillGoods> list(String time) {
        return seckillGoodsService.list(time);
    }

    /**
     * 根据商品Id查询商品详情
     *
     * @param time
     * @param id
     * @return
     */
    @RequestMapping(value = "/one")
    public SeckillGoods one(String time, Long id) {
        return seckillGoodsService.one(time, id);
    }


}
